package com.fen.demo013;

import org.springframework.context.support.GenericXmlApplicationContext;

/**
 * @author : lrf
 * @description :
 * @tip :
 * @date : 2019/3/22
 */
public class App {

    public static void main(String[] args) {

        GenericXmlApplicationContext parent = new GenericXmlApplicationContext();
        parent.load("classpath:demo013/parent-context.xml");
        parent.refresh();

        GenericXmlApplicationContext child = new GenericXmlApplicationContext();
        child.load("classpath:demo013/child-context.xml");
        child.setParent(parent);
        child.refresh();

        Song1 song1 = child.getBean("song1", Song1.class);
        Song2 song2 = child.getBean("song2", Song2.class);
        Song3 song3 = child.getBean("song3", Song3.class);

        System.out.println("from parent context " + song1.getTitle());
        System.out.println("from child context " + song2.getTitle());
        System.out.println("from parent context " + song3.getTitle());


        child.close();
        parent.close();
    }
}











